package com.pm.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pm.common.annotation.Log;
import com.pm.common.core.controller.BaseController;
import com.pm.common.core.domain.AjaxResult;
import com.pm.common.enums.BusinessType;
import com.pm.business.domain.CompeteEnterpriseCertificate;
import com.pm.business.service.ICompeteEnterpriseCertificateService;
import com.pm.common.utils.poi.ExcelUtil;
import com.pm.common.core.page.TableDataInfo;

/**
 * 企业证书Controller
 * 
 * @author zxl
 * @date 2022-05-07
 */
@RestController
@RequestMapping("/business/compete_enterprise_certificate")
public class CompeteEnterpriseCertificateController extends BaseController
{
    @Autowired
    private ICompeteEnterpriseCertificateService competeEnterpriseCertificateService;

    /**
     * 查询企业证书列表
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_certificate:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompeteEnterpriseCertificate competeEnterpriseCertificate)
    {
        startPage();
        List<CompeteEnterpriseCertificate> list = competeEnterpriseCertificateService.selectCompeteEnterpriseCertificateList(competeEnterpriseCertificate);
        return getDataTable(list);
    }

    /**
     * 导出企业证书列表
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_certificate:export')")
    @Log(title = "企业证书", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompeteEnterpriseCertificate competeEnterpriseCertificate)
    {
        List<CompeteEnterpriseCertificate> list = competeEnterpriseCertificateService.selectCompeteEnterpriseCertificateList(competeEnterpriseCertificate);
        ExcelUtil<CompeteEnterpriseCertificate> util = new ExcelUtil<CompeteEnterpriseCertificate>(CompeteEnterpriseCertificate.class);
        util.exportExcel(response, list, "企业证书数据");
    }

    /**
     * 获取企业证书详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_certificate:query')")
    @GetMapping(value = "/{certificateId}")
    public AjaxResult getInfo(@PathVariable("certificateId") Long certificateId)
    {
        return AjaxResult.success(competeEnterpriseCertificateService.selectCompeteEnterpriseCertificateByCertificateId(certificateId));
    }

    /**
     * 新增企业证书
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_certificate:add')")
    @Log(title = "企业证书", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompeteEnterpriseCertificate competeEnterpriseCertificate)
    {
        return toAjax(competeEnterpriseCertificateService.insertCompeteEnterpriseCertificate(competeEnterpriseCertificate));
    }

    /**
     * 修改企业证书
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_certificate:edit')")
    @Log(title = "企业证书", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompeteEnterpriseCertificate competeEnterpriseCertificate)
    {
        return toAjax(competeEnterpriseCertificateService.updateCompeteEnterpriseCertificate(competeEnterpriseCertificate));
    }

    /**
     * 删除企业证书
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_certificate:remove')")
    @Log(title = "企业证书", businessType = BusinessType.DELETE)
	@DeleteMapping("/{certificateIds}")
    public AjaxResult remove(@PathVariable Long[] certificateIds)
    {
        return toAjax(competeEnterpriseCertificateService.deleteCompeteEnterpriseCertificateByCertificateIds(certificateIds));
    }
}
